;快慢指针
(define (check-cycle? items)
    (define (move-step x)
        (if (null? (cdr x))
            `()
            (cdr x)
        )
    )
    (define (iter move steps slow-point fast-point)
        (cond 
            ((> move steps) #f)
            ((null? slow-point) #f)
            ((null? (cdr fast-point)) #f)
            ((eq? slow-point fast-point) #t)
            (else (iter 
                    (+ move 1)
                    steps
                    (move-step slow-point)
                    (move-step (move-step fast-point))    
                )
            )
        )
    )
    (iter 0 1000 (cdr items) (cddr items) )
)



(define (make-cycle x)
    (set-cdr! (last-pair x) x)
    x
)

(define (last-pair x)
    (if (null? x)
        x
        (last-pair (cdr x))
    )
)
(define z (make-cycle (list `a `b `c)))
(display (check-cycle? z))
(newline)
(display (check-cycle? (list 1 2 3 1 2 3 1)))
(exit)